<?php
/**
 * Created by PhpStorm.
 * User: Yieong
 * Date: 14/11/18
 * Time: 下午9:55
 */

class ModPlatform extends Model {

    private $table = 'tblPlatform';

    // 表名
    public function tableName(){
        return $this->table;
    }

    public static function model($className=__CLASS__){
        return parent::model($className);
    }

    public function getDbConnection(){
        return Yii::app()->dbAuth;
    }

    public function select($params = array()){

        $criteria = new CDbCriteria();
        if(!empty($params['search'])){
            $criteria->addSearchCondition('PlatformName', $params['search']);
        }
        $criteria->order = ' SortNum ASC ';

        $tmp = $this->findAll($criteria);

        $result = array();
        if(!empty($tmp)){
            foreach($tmp as $v){
                $result[$v->PlatformID] = array(
                    'PlatformID'     => $v->PlatformID,
                    'PlatformSrc'    => $v->PlatformSrc,
                    'PlatformName'   => $v->PlatformName,
                    'SortNum'        => $v->SortNum
                );
            }
        }

        return $result;
    }
} 